define(['../../../../js/lib/other/sweet-alert'],function() {
    return ['$scope','$location', '$interval','$timeout','bizProxy', function($scope,$location,$interval,$timeout,bizProxy) {
		$scope.$emit("top-show",'true');//顶部显示
    	$scope.$emit('menuTypeLight','mine'); 	//控制底部menu高亮
    	$scope.$emit('bub-menu','true'); 	//隐藏底部menu
    	$scope.$emit('flag-tag','7');//显示底部文字
    	
        //初始值
        $scope.userName = "",$scope.idType = "",$scope.documentsNo = "",$scope.email = "";

        //提交确认
        $scope.subConfirm = function(){
        	if(! $scope.userName){
        		$scope.$emit("promptAlertMsg","用户姓名不能为空");
        		$scope.$emit("showCollect",true);
        		$timeout(function(){
        			$scope.$emit("showCollect",false);
        		},transData.promptTime);
                return;
    		}else if(! $scope.idType){
    			$scope.$emit("promptAlertMsg","请选择证件类型");
        		$scope.$emit("showCollect",true);
        		$timeout(function(){
        			$scope.$emit("showCollect",false);
        		},transData.promptTime);
                return;
    		}else if(! $scope.documentsNo){
    			$scope.$emit("promptAlertMsg","证件号码不能为空");
        		$scope.$emit("showCollect",true);
        		$timeout(function(){
        			$scope.$emit("showCollect",false);
        		},transData.promptTime);
                return;
    		}else{
    			if(!_YHC_util.IdentityCodeValid($scope.documentsNo) && $scope.idType === '身份证'){
    				$scope.$emit("promptAlertMsg","无效身份证号");
        			$scope.$emit("showCollect",true);
        			$timeout(function(){
        				$scope.$emit("showCollect",false);
        			},transData.promptTime);
                    return;
    			}else if( !_YHC_util.isValidBusCode($scope.documentsNo) && $scope.idType === '营业执照'){
    				$scope.$emit("promptAlertMsg","无效营业执照号");
        			$scope.$emit("showCollect",true);
        			$timeout(function(){
        				$scope.$emit("showCollect",false);
        			},transData.promptTime);
                    return;
    			}else{
    				if($scope.email){
    	    			if(!_YHC_util.fChkMail($scope.email)){
    	    				$scope.$emit("promptAlertMsg","邮箱格式不正确");
    	        			$scope.$emit("showCollect",true);
    	        			$timeout(function(){
    	        				$scope.$emit("showCollect",false);
    	        			},transData.promptTime);
    	        			return;
    	    			}else{
    	    				subPtData();
    	    			}
    	    		}else{
    	    			subPtData();
    	    		}
    			}
    		}
        }
        
        //调用代理提交普通用户完善资料
        function subPtData(){
        	var headerInfo = {},bizInfo = {};
        	headerInfo.pageNum = '';
        	headerInfo.pageSize = '';
        	headerInfo.sessionId = transData.sessionId;
        	
        	bizInfo.userName = $scope.userName;
        	if($scope.idType == "身份证"){
        		bizInfo.idType = "1";
        	}else if($scope.idType == "营业执照"){
        		bizInfo.idType = "2";
        	}
        	
        	bizInfo.idNo = $scope.documentsNo;
        	bizInfo.email = $scope.email;
        	
    		$scope.$emit("loadingChange",true);
    		bizProxy.queryProxyBizData("userExt",headerInfo,bizInfo,
    				function(tempData){//SUCCESS
    					$scope.$emit("loadingChange",false);
    					assignmentData(tempData);
						$timeout(function(){
							var bizInfoPt = JSON.stringify(bizInfo);
							$scope.$emit("goNext","/completeLsData/"+bizInfoPt);
						},100);
		    		},function(data){
		    			if(data != ""){//FAIL
		    				$scope.$emit("loadingChange",false);
							if(data.errorCode == ERROR_CODE.noLogin){
								FIREFLY("", data.errorMsg,"",function(){
										//调用退出登录
										transData.mobileNo = "";
		    							transData.password = "";
		    							transData.sessionId = "";
		    							transData.userType = "";
		    							resultData.loginUserData = "";
		    							resultData.loginUserData = "";
		    							$timeout(function(){
		    								$scope.$emit("goNext","/mine");
		    							},0);
								});
							}else{
								$scope.$emit("promptAlertMsg",data.errorMsg);
								$scope.$emit("showCollect",true);
								$timeout(function(){
									$scope.$emit("showCollect",false);
								},transData.promptTime);
							}
		    			}else{
		    				$scope.$emit("loadingChange",false);
							$scope.$emit("promptAlertMsg","连接超时");
							$scope.$emit("showCollect",true);
							$timeout(function(){
								$scope.$emit("showCollect",false);
							},transData.promptTime);
		    			}
		    		});
        }
        
    	//监听跳过点击事件
        $scope.$on('skipEvent', function(event,data){
            if(data){
                $scope.$emit("goNext","/minePt");
            }
        });

    	
        $scope.$apply();
    }];
});